<template>
  <div class="reports">
    <div class="reports_header">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>订单管理</el-breadcrumb-item>
        <el-breadcrumb-item>订单列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-card shadow="hover" class="reports_con">
      <div id="main" style="width: 1200px;height:600px;"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'rePorts',
  data() {
    return {
      // 折线图需要合并的格式
      options: {
        title: {
          text: '用户来源',
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3',
            },
          },
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: 'value',
          },
        ],
      },
    }
  },
  methods: {},

  // 页面渲染后再执行数据
  async mounted() {
    const { data: infores } = await this.$http.get('reports/type/1')

    var chartDom = document.getElementById('main')
    var myChart = echarts.init(chartDom)

    // 合并格式与数据
    const value = { ...this.options, ...infores.data }
    myChart.setOption(value)
  },
}
</script>

<style lang='less' scoped>
.reports_header {
  .el-breadcrumb {
    font-size: 17px;
  }
}
.reports_con {
  margin-top: 30px;
  height: 90%;
  background: #fff;
  padding: 20px;
}
</style>